﻿using System;
using System.Collections.Generic;

namespace YArchitech.Plumbing
{
	public class HYPipeData
	{
		public HYPipeData()
		{
			this.valvesList = new List<ValveAndFitting>();
		}

		public HYPipeData(HYPipeData hyPipe)
		{
			this.preSerialNum = hyPipe.preSerialNum;
			this.serialNum = hyPipe.serialNum;
			this.material = hyPipe.material;
			this.diameter = hyPipe.diameter;
			this.interDia = hyPipe.interDia;
			this.thickness = hyPipe.thickness;
			this.length = hyPipe.length;
			this.resCoefLocal = hyPipe.resCoefLocal;
			this.load = hyPipe.load;
			this.flow = hyPipe.flow;
			this.speed = hyPipe.speed;
			this.resistanceFrict = hyPipe.resistanceFrict;
			this.dragForce = hyPipe.dragForce;
			this.pressDynamic = hyPipe.pressDynamic;
			this.resistanceLocal = hyPipe.resistanceLocal;
			this.resistance = hyPipe.resistance;
			this.outDiameter = hyPipe.outDiameter;
			this.valvesList = this.InitialValveAndFittings(hyPipe.valvesList);
		}

		public double GetResistanceLocal()
		{
			return 0.0;
		}

		private IList<ValveAndFitting> InitialValveAndFittings(IList<ValveAndFitting> listVaF)
		{
			IList<ValveAndFitting> list = new List<ValveAndFitting>();
			if (listVaF == null || listVaF.Count < 1)
			{
				return list;
			}
			foreach (ValveAndFitting valveAndFitting in listVaF)
			{
				ValveAndFitting item = new ValveAndFitting(valveAndFitting);
				list.Add(item);
			}
			return list;
		}

		private double GetTotalCoefLocal()
		{
			double num = 0.0;
			if (this.ValvesList.Count > 0)
			{
				foreach (ValveAndFitting valveAndFitting in this.ValvesList)
				{
					ValveString valveStringByName = GHCalcMethods.GetValveStringByName(valveAndFitting.VFName);
					if (valveStringByName == ValveString.闸阀 || valveStringByName == ValveString.截止阀 || valveStringByName == ValveString.斜杆截止阀 || valveStringByName == ValveString.弯头 || valveStringByName == ValveString.乙字弯 || valveStringByName == ValveString.扩弯 || valveStringByName == ValveString.方形补偿器 || valveStringByName == ValveString.套管补偿器)
					{
						num += GHCalcMethods.GetLocalCoeff(valveStringByName, this.Diameter) * valveAndFitting.Value;
					}
					if (valveStringByName == ValveString.其他 || valveStringByName == ValveString.散热器)
					{
						num += valveAndFitting.Value;
					}
					if (valveStringByName == ValveString.分合流四通 || valveStringByName == ValveString.分流三通 || valveStringByName == ValveString.合流三通 || valveStringByName == ValveString.旁流三通 || valveStringByName == ValveString.直流三通 || valveStringByName == ValveString.直流四通)
					{
						num += GHCalcMethods.GetLocalCoeff(valveStringByName, this.Diameter);
					}
				}
			}
			return num;
		}

		private int GetDiameter(double outDia)
		{
			int num = 0;
			for (int i = 0; i < 3; i++)
			{
				if (ConstantOfGHCalc.XPAPWJB[i] == outDia)
				{
					num = i;
					break;
				}
			}
			return ConstantOfGHCalc.XPAPGJB[num];
		}

		public string PreSerialNum
		{
			get
			{
				return this.preSerialNum;
			}
			set
			{
				this.preSerialNum = value;
			}
		}

		public string SerialNum
		{
			get
			{
				return this.serialNum;
			}
			set
			{
				this.serialNum = value;
			}
		}

		public int Material
		{
			get
			{
				return this.material;
			}
			set
			{
				this.material = value;
			}
		}

		public double InterDia
		{
			get
			{
				return this.interDia;
			}
			set
			{
				this.interDia = value;
			}
		}

		public int Diameter
		{
			get
			{
				if (this.diameter == 0)
				{
					this.diameter = this.GetDiameter(Convert.ToDouble(this.OutDiameter));
				}
				return this.diameter;
			}
			set
			{
				this.diameter = value;
			}
		}

		public double Thickness
		{
			get
			{
				return this.thickness;
			}
			set
			{
				this.thickness = value;
			}
		}

		public double Length
		{
			get
			{
				return this.length;
			}
			set
			{
				this.length = value;
			}
		}

		public double Load
		{
			get
			{
				return this.load;
			}
			set
			{
				this.load = value;
			}
		}

		public double Flow
		{
			get
			{
				return this.flow;
			}
			set
			{
				this.flow = value;
			}
		}

		public double Speed
		{
			get
			{
				return this.speed;
			}
			set
			{
				this.speed = value;
			}
		}

		public double ResistanceFrict
		{
			get
			{
				return this.resistanceFrict;
			}
			set
			{
				this.resistanceFrict = value;
			}
		}

		public double DragForce
		{
			get
			{
				return this.dragForce;
			}
			set
			{
				this.dragForce = value;
			}
		}

		public double PressDynamic
		{
			get
			{
				return this.pressDynamic;
			}
			set
			{
				this.pressDynamic = value;
			}
		}

		public double ResistanceLocal
		{
			get
			{
				return this.resistanceLocal;
			}
			set
			{
				this.resistanceLocal = value;
			}
		}

		public double Resistance
		{
			get
			{
				return this.resistance;
			}
			set
			{
				this.resistance = value;
			}
		}

		public string OutDiameter
		{
			get
			{
				return this.outDiameter;
			}
			set
			{
				this.outDiameter = value;
			}
		}

		public double ResCoefLocal
		{
			get
			{
				return this.GetTotalCoefLocal();
			}
			set
			{
				this.resCoefLocal = value;
			}
		}

		public IList<ValveAndFitting> ValvesList
		{
			get
			{
				return this.valvesList;
			}
			set
			{
				this.valvesList = value;
			}
		}

		private string preSerialNum;

		private string serialNum;

		private int material;

		private int diameter;

		private double interDia;

		private double thickness;

		private double length;

		private double load;

		private double flow;

		private double speed;

		private double resistanceFrict;

		private double dragForce;

		private double pressDynamic;

		private double resistanceLocal;

		private double resistance;

		private string outDiameter;

		private double resCoefLocal;

		private IList<ValveAndFitting> valvesList;
	}
}
